package app.bigdata;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Map.Entry;

public class RecordStatistics{
	
	public RecordStatistics(ArrayList<String> arrayList){
		
		Map<String, Integer> occur = new HashMap<String, Integer>();
		
		for(String word : arrayList){
			occur.put(word, occur.containsKey(word) ? occur.get(word) + 1 : 1);
		}
		
		int count = 0;
		for(Entry<String, Integer> entry : occur.entrySet() ){
			count = count+entry.getValue();
			//System.out.println("Star : "+entry.getKey()+" , frequency : "+entry.getValue());
		}

		if(!Constants.STAR_BASE){
			for(Entry<String, Integer> entry : occur.entrySet() ){
				System.out.println("Star : "+entry.getKey()+
						" , percentage : "+ ((float)entry.getValue()/(float)count)*100 + "%" );
			}
		}else{
			for(Entry<String, Integer> entry : occur.entrySet() ){
				System.out.println("Centroid : "+entry.getKey()+
						" , percentage : "+ ((float)entry.getValue()/(float)count)*100 + "%" );
			}	
		}
		
	}
	
}